streamlit-nightly 1.45.1.dev20250511__py3-none-any.whl → 1.45.2.dev20250513__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/__init__.py +1 -0
- streamlit/auth_util.py +6 -6
- streamlit/commands/echo.py +5 -3
- streamlit/commands/experimental_query_params.py +1 -1
- streamlit/commands/navigation.py +1 -4
- streamlit/components/v1/custom_component.py +2 -2
- streamlit/config.py +16 -18
- streamlit/config_util.py +6 -7
- streamlit/connections/sql_connection.py +1 -1
- streamlit/dataframe_util.py +50 -51
- streamlit/delta_generator.py +4 -1
- streamlit/deprecation_util.py +5 -5
- streamlit/elements/arrow.py +1 -1
- streamlit/elements/deck_gl_json_chart.py +1 -4
- streamlit/elements/doc_string.py +5 -10
- streamlit/elements/exception.py +5 -7
- streamlit/elements/layouts.py +4 -3
- streamlit/elements/lib/built_in_chart_utils.py +22 -22
- streamlit/elements/lib/pandas_styler_utils.py +6 -8
- streamlit/elements/lib/policies.py +1 -1
- streamlit/elements/map.py +2 -8
- streamlit/elements/markdown.py +1 -4
- streamlit/elements/media.py +50 -2
- streamlit/elements/metric.py +9 -10
- streamlit/elements/spinner.py +1 -1
- streamlit/elements/vega_charts.py +1 -1
- streamlit/elements/widgets/audio_input.py +1 -4
- streamlit/elements/widgets/camera_input.py +1 -4
- streamlit/elements/widgets/chat.py +52 -5
- streamlit/elements/widgets/data_editor.py +1 -1
- streamlit/elements/widgets/slider.py +4 -5
- streamlit/elements/widgets/time_widgets.py +1 -4
- streamlit/elements/write.py +2 -2
- streamlit/env_util.py +2 -7
- streamlit/error_util.py +15 -8
- streamlit/errors.py +11 -8
- streamlit/file_util.py +6 -3
- streamlit/git_util.py +26 -21
- streamlit/hello/dataframe_demo.py +1 -1
- streamlit/hello/mapping_demo.py +1 -1
- streamlit/hello/plotting_demo.py +3 -3
- streamlit/hello/streamlit_app.py +1 -1
- streamlit/hello/utils.py +2 -1
- streamlit/logger.py +4 -5
- streamlit/proto/Audio_pb2.py +4 -3
- streamlit/proto/Audio_pb2.pyi +8 -1
- streamlit/proto/Block_pb2.py +5 -5
- streamlit/proto/Block_pb2.pyi +7 -1
- streamlit/proto/ChatInput_pb2.py +8 -7
- streamlit/proto/ChatInput_pb2.pyi +10 -1
- streamlit/proto/Video_pb2.py +8 -7
- streamlit/proto/Video_pb2.pyi +8 -1
- streamlit/runtime/app_session.py +5 -5
- streamlit/runtime/caching/cache_data_api.py +2 -2
- streamlit/runtime/caching/cache_resource_api.py +1 -1
- streamlit/runtime/caching/cache_utils.py +3 -3
- streamlit/runtime/caching/hashing.py +10 -10
- streamlit/runtime/credentials.py +9 -8
- streamlit/runtime/forward_msg_queue.py +1 -1
- streamlit/runtime/memory_media_file_storage.py +5 -4
- streamlit/runtime/memory_uploaded_file_manager.py +1 -1
- streamlit/runtime/metrics_util.py +2 -2
- streamlit/runtime/runtime.py +1 -1
- streamlit/runtime/scriptrunner/exec_code.py +1 -1
- streamlit/runtime/scriptrunner/script_cache.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +10 -3
- streamlit/runtime/scriptrunner_utils/script_requests.py +3 -3
- streamlit/runtime/scriptrunner_utils/script_run_context.py +3 -3
- streamlit/runtime/secrets.py +6 -7
- streamlit/runtime/state/query_params.py +3 -5
- streamlit/runtime/state/session_state.py +15 -15
- streamlit/runtime/stats.py +1 -1
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.B5LmzpSn.js → ErrorOutline.esm.CxkgXqSh.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.BgWveG3s.js → FileDownload.esm.DVrjmwoh.js} +1 -1
- streamlit/static/static/js/{FileHelper.DepIpP48.js → FileHelper.CMA9s0t3.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.C_BjP_35.js → FormClearHelper.Ca3GFjxv.js} +1 -1
- streamlit/static/static/js/{Hooks.BpH4YuRQ.js → Hooks.BpCPXt5n.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CjdwGigq.js → InputInstructions.BO_BnHv5.js} +1 -1
- streamlit/static/static/js/{ProgressBar.D1hXcW3N.js → ProgressBar.Ctk1m4EX.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.A1T2s6z-.js → RenderInPortalIfExists.kuKoxpXt.js} +1 -1
- streamlit/static/static/js/{Toolbar.y7vr7z0G.js → Toolbar.Cde1fEcQ.js} +1 -1
- streamlit/static/static/js/{base-input.BKhd-BLG.js → base-input.BwCmIYba.js} +1 -1
- streamlit/static/static/js/{checkbox.DC-GFdrh.js → checkbox.CwPOyuag.js} +1 -1
- streamlit/static/static/js/{createSuper.D5WUtJEy.js → createSuper.BMtevhyt.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.BPJ38mWp.js → data-grid-overlay-editor.gtfE9z1L.js} +1 -1
- streamlit/static/static/js/{downloader.C6a4LRBw.js → downloader.-58ZXBvx.js} +1 -1
- streamlit/static/static/js/{es6.DgMlYq8q.js → es6.6JpsZqpF.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.BpQxex73.js → iframeResizer.contentWindow.Dvm_jxul.js} +1 -1
- streamlit/static/static/js/{index.CiO2JPl_.js → index.9Bu4pGgs.js} +1 -1
- streamlit/static/static/js/{index.4Gtr9egA.js → index.B1T1N6vQ.js} +1 -1
- streamlit/static/static/js/{index.20fI9wQF.js → index.B9LBeTzL.js} +1 -1
- streamlit/static/static/js/{index.VPO2zcSN.js → index.BXdNB_A0.js} +1 -1
- streamlit/static/static/js/{index.sKXwUANU.js → index.Bd91GXu8.js} +1 -1
- streamlit/static/static/js/{index.DT0CWGt3.js → index.BdEKCy-o.js} +1 -1
- streamlit/static/static/js/{index.D3tgBU6x.js → index.BhODUTaJ.js} +1 -1
- streamlit/static/static/js/{index.BcbB70bz.js → index.BjtSRm-c.js} +1 -1
- streamlit/static/static/js/{index.DPiBGVm8.js → index.BnK8pWHN.js} +1 -1
- streamlit/static/static/js/{index.49Q6A5_9.js → index.C5xsotRs.js} +1 -1
- streamlit/static/static/js/{index.xIQLhQKv.js → index.CD3lJu6g.js} +1 -1
- streamlit/static/static/js/{index.BydIp_VR.js → index.CGJjlswG.js} +1 -1
- streamlit/static/static/js/{index.Bj81ZRkx.js → index.CIZd1q4K.js} +1 -1
- streamlit/static/static/js/{index.5k30-U6O.js → index.CZy9JHE4.js} +2 -2
- streamlit/static/static/js/{index.D5PANKHd.js → index.Ce-7kIl6.js} +1 -1
- streamlit/static/static/js/{index.Bo-z1JM2.js → index.CiiU1-bS.js} +1 -1
- streamlit/static/static/js/{index.Cqla7uBZ.js → index.ClE8XHxl.js} +1 -1
- streamlit/static/static/js/{index.CY8tg9lY.js → index.CvKH37SN.js} +1 -1
- streamlit/static/static/js/{index.CkBnHCIQ.js → index.D0G-y_z6.js} +1 -1
- streamlit/static/static/js/{index.B3UoUwtN.js → index.D1ccH_2Z.js} +1 -1
- streamlit/static/static/js/{index.DB42JCH0.js → index.D3ES4sSL.js} +1 -1
- streamlit/static/static/js/{index.BLpDfH1w.js → index.DJ0X7aeY.js} +1 -1
- streamlit/static/static/js/{index.BRN41-Jy.js → index.DNNQBTM6.js} +1 -1
- streamlit/static/static/js/{index.br6zwNIk.js → index.DQJE0i9s.js} +62 -62
- streamlit/static/static/js/{index.DSPS70gp.js → index.DR9ekgzX.js} +1 -1
- streamlit/static/static/js/{index.BbhQIRth.js → index.DUizq_aW.js} +1 -1
- streamlit/static/static/js/{index.ryD8hMpi.js → index.DVE5BhiT.js} +1 -1
- streamlit/static/static/js/{index.C2GjbQtf.js → index.DW60zbv4.js} +1 -1
- streamlit/static/static/js/{index.BhGEwO_d.js → index.DenamHJl.js} +1 -1
- streamlit/static/static/js/{index._oOkpIXS.js → index.DgnhzFgr.js} +1 -1
- streamlit/static/static/js/{index.CHnID3dI.js → index.Dk_aZplH.js} +1 -1
- streamlit/static/static/js/index.Dqcp7EZB.js +779 -0
- streamlit/static/static/js/{index.DAO4Lj-D.js → index.NfOJ2GJ6.js} +1 -1
- streamlit/static/static/js/{index.CcvbHTJu.js → index.WVgPkrrw.js} +1 -1
- streamlit/static/static/js/{index.Du1Pbz0y.js → index.bkU6rhIM.js} +1 -1
- streamlit/static/static/js/{index.Cfi3u2-T.js → index.hQ5adhxG.js} +1 -1
- streamlit/static/static/js/{index.B8ca7fYO.js → index.lYSTjxV_.js} +1 -1
- streamlit/static/static/js/{input.CNjMviuo.js → input.JEUWF6Z-.js} +1 -1
- streamlit/static/static/js/{memory.f8X97LPt.js → memory.BToPJrCN.js} +1 -1
- streamlit/static/static/js/{mergeWith.DU9BO8BA.js → mergeWith.DGon2YId.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.xJPBNdGQ.js → number-overlay-editor.kqkFTYSn.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.BjPX9m9m.js → possibleConstructorReturn.twGQoCQl.js} +1 -1
- streamlit/static/static/js/{sandbox.B23JuuVd.js → sandbox.o85HOKwq.js} +1 -1
- streamlit/static/static/js/{textarea.DodnI6GX.js → textarea.CdOYpTta.js} +1 -1
- streamlit/static/static/js/{timepicker.ClHKNfP9.js → timepicker.Cy1BKBo3.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CK6YGgcW.js → toConsumableArray.BVXfsvDc.js} +1 -1
- streamlit/static/static/js/{uniqueId.BAAVLIKj.js → uniqueId.Dz7-nY8K.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.B1oropKY.js → useBasicWidgetState.CeKdNkz-.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.CHQJz2sf.js → useOnInputChange.CM8BtP-c.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.DZ1W8JUx.js → withFullScreenWrapper.DuyW554J.js} +1 -1
- streamlit/string_util.py +1 -4
- streamlit/temporary_directory.py +2 -2
- streamlit/testing/v1/app_test.py +2 -2
- streamlit/testing/v1/element_tree.py +10 -9
- streamlit/testing/v1/local_script_runner.py +1 -4
- streamlit/type_util.py +2 -5
- streamlit/watcher/folder_black_list.py +1 -1
- streamlit/watcher/local_sources_watcher.py +5 -3
- streamlit/watcher/path_watcher.py +3 -6
- streamlit/watcher/polling_path_watcher.py +8 -7
- streamlit/watcher/util.py +6 -5
- streamlit/web/bootstrap.py +4 -4
- streamlit/web/cli.py +13 -13
- streamlit/web/server/app_static_file_handler.py +1 -1
- streamlit/web/server/authlib_tornado_integration.py +6 -1
- streamlit/web/server/oauth_authlib_routes.py +3 -3
- streamlit/web/server/oidc_mixin.py +15 -3
- streamlit/web/server/routes.py +11 -11
- streamlit/web/server/stats_request_handler.py +2 -2
- {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/RECORD +164 -164
- streamlit/static/static/js/index.BgEbLy94.js +0 -779
- {streamlit_nightly-1.45.1.dev20250511.data → streamlit_nightly-1.45.2.dev20250513.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.45.1.dev20250511.dist-info → streamlit_nightly-1.45.2.dev20250513.dist-info}/top_level.txt +0 -0
streamlit/__init__.py
CHANGED
streamlit/auth_util.py
CHANGED
@@ -32,21 +32,21 @@ if TYPE_CHECKING:
|
|
32
32
|
class AuthCache:
|
33
33
|
"""Simple cache implementation for storing info required for Authlib."""
|
34
34
|
|
35
|
-
def __init__(self):
|
36
|
-
self.cache = {}
|
35
|
+
def __init__(self) -> None:
|
36
|
+
self.cache: dict[str, Any] = {}
|
37
37
|
|
38
|
-
def get(self, key):
|
38
|
+
def get(self, key: str) -> Any:
|
39
39
|
return self.cache.get(key)
|
40
40
|
|
41
41
|
# for set method, we are follow the same signature used in Authlib
|
42
42
|
# the expires_in is not used in our case
|
43
|
-
def set(self, key, value, expires_in): # noqa: ARG002
|
43
|
+
def set(self, key: str, value: Any, expires_in: int | None = None) -> None: # noqa: ARG002
|
44
44
|
self.cache[key] = value
|
45
45
|
|
46
|
-
def get_dict(self):
|
46
|
+
def get_dict(self) -> dict[str, Any]:
|
47
47
|
return self.cache
|
48
48
|
|
49
|
-
def delete(self, key):
|
49
|
+
def delete(self, key: str) -> None:
|
50
50
|
self.cache.pop(key, None)
|
51
51
|
|
52
52
|
|
streamlit/commands/echo.py
CHANGED
@@ -19,12 +19,12 @@ import contextlib
|
|
19
19
|
import re
|
20
20
|
import textwrap
|
21
21
|
import traceback
|
22
|
-
from typing import TYPE_CHECKING, Any
|
22
|
+
from typing import TYPE_CHECKING, Any, Literal
|
23
23
|
|
24
24
|
from streamlit.runtime.metrics_util import gather_metrics
|
25
25
|
|
26
26
|
if TYPE_CHECKING:
|
27
|
-
from collections.abc import Iterable
|
27
|
+
from collections.abc import Generator, Iterable
|
28
28
|
|
29
29
|
_SPACES_RE = re.compile("\\s*")
|
30
30
|
_EMPTY_LINE_RE = re.compile("\\s*\n")
|
@@ -32,7 +32,9 @@ _EMPTY_LINE_RE = re.compile("\\s*\n")
|
|
32
32
|
|
33
33
|
@gather_metrics("echo")
|
34
34
|
@contextlib.contextmanager
|
35
|
-
def echo(
|
35
|
+
def echo(
|
36
|
+
code_location: Literal["above", "below"] = "above",
|
37
|
+
) -> Generator[None, None, None]:
|
36
38
|
"""Use in a `with` block to draw some code on the app, then execute it.
|
37
39
|
|
38
40
|
Parameters
|
@@ -123,7 +123,7 @@ def _extract_key_query_params(
|
|
123
123
|
item.lower()
|
124
124
|
for sublist in [
|
125
125
|
[value.lower() for value in query_params[key]]
|
126
|
-
for key in query_params
|
126
|
+
for key in query_params
|
127
127
|
if key.lower() == param_key and query_params.get(key)
|
128
128
|
]
|
129
129
|
for item in sublist
|
streamlit/commands/navigation.py
CHANGED
@@ -311,10 +311,7 @@ def _navigation(
|
|
311
311
|
# Build the pagehash-to-pageinfo mapping.
|
312
312
|
for section_header in nav_sections:
|
313
313
|
for page in nav_sections[section_header]:
|
314
|
-
if isinstance(page._page, Path)
|
315
|
-
script_path = str(page._page)
|
316
|
-
else:
|
317
|
-
script_path = ""
|
314
|
+
script_path = str(page._page) if isinstance(page._page, Path) else ""
|
318
315
|
|
319
316
|
script_hash = page._script_hash
|
320
317
|
if script_hash in pagehash_to_pageinfo:
|
@@ -183,7 +183,7 @@ And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
|
|
183
183
|
# other arguments change, and the component's iframe won't be
|
184
184
|
# remounted on the frontend.
|
185
185
|
|
186
|
-
def marshall_element_args():
|
186
|
+
def marshall_element_args() -> None:
|
187
187
|
element.component_instance.json_args = serialized_json_args
|
188
188
|
element.component_instance.special_args.extend(special_args)
|
189
189
|
|
@@ -210,7 +210,7 @@ And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
|
|
210
210
|
)
|
211
211
|
element.component_instance.id = computed_id
|
212
212
|
|
213
|
-
def deserialize_component(ui_value):
|
213
|
+
def deserialize_component(ui_value: Any) -> Any:
|
214
214
|
# ui_value is an object from json, an ArrowTable proto, or a bytearray
|
215
215
|
return ui_value
|
216
216
|
|
streamlit/config.py
CHANGED
@@ -728,15 +728,12 @@ def _server_headless() -> bool:
|
|
728
728
|
Default: false unless (1) we are on a Linux box where DISPLAY is unset, or
|
729
729
|
(2) we are running in the Streamlit Atom plugin.
|
730
730
|
"""
|
731
|
-
if
|
731
|
+
# Check if we are running in Linux and DISPLAY is unset
|
732
|
+
return (
|
732
733
|
env_util.IS_LINUX_OR_BSD
|
733
734
|
and not os.getenv("DISPLAY")
|
734
735
|
and not os.getenv("WAYLAND_DISPLAY")
|
735
|
-
)
|
736
|
-
# We're running in Linux and DISPLAY is unset
|
737
|
-
return True
|
738
|
-
|
739
|
-
return False
|
736
|
+
)
|
740
737
|
|
741
738
|
|
742
739
|
_create_option(
|
@@ -1629,10 +1626,11 @@ def _check_conflicts() -> None:
|
|
1629
1626
|
)
|
1630
1627
|
|
1631
1628
|
# XSRF conflicts
|
1632
|
-
if get_option("server.enableXsrfProtection")
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1629
|
+
if get_option("server.enableXsrfProtection") and (
|
1630
|
+
not get_option("server.enableCORS") or get_option("global.developmentMode")
|
1631
|
+
):
|
1632
|
+
LOGGER.warning(
|
1633
|
+
"""
|
1636
1634
|
Warning: the config option 'server.enableCORS=false' is not compatible with
|
1637
1635
|
'server.enableXsrfProtection=true'.
|
1638
1636
|
As a result, 'server.enableCORS' is being overridden to 'true'.
|
@@ -1644,7 +1642,7 @@ cross-origin resource sharing.
|
|
1644
1642
|
|
1645
1643
|
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
|
1646
1644
|
"""
|
1647
|
-
|
1645
|
+
)
|
1648
1646
|
|
1649
1647
|
|
1650
1648
|
def _set_development_mode() -> None:
|
@@ -1653,7 +1651,7 @@ def _set_development_mode() -> None:
|
|
1653
1651
|
|
1654
1652
|
def on_config_parsed(
|
1655
1653
|
func: Callable[[], None], force_connect: bool = False, lock: bool = False
|
1656
|
-
) -> Callable[[],
|
1654
|
+
) -> Callable[[], None]:
|
1657
1655
|
"""Wait for the config file to be parsed then call func.
|
1658
1656
|
|
1659
1657
|
If the config file has already been parsed, just calls func immediately
|
@@ -1673,7 +1671,7 @@ def on_config_parsed(
|
|
1673
1671
|
|
1674
1672
|
Returns
|
1675
1673
|
-------
|
1676
|
-
Callable[[],
|
1674
|
+
Callable[[], None]
|
1677
1675
|
A function that the caller can use to deregister func.
|
1678
1676
|
"""
|
1679
1677
|
|
@@ -1682,13 +1680,13 @@ def on_config_parsed(
|
|
1682
1680
|
# leading to a memory leak because the Signal will keep a reference of the
|
1683
1681
|
# callable argument. When the callable argument is an object method, then
|
1684
1682
|
# the reference to that object won't be released.
|
1685
|
-
def receiver(_):
|
1686
|
-
|
1683
|
+
def receiver(_: Any) -> None:
|
1684
|
+
func_with_lock()
|
1687
1685
|
|
1688
|
-
def disconnect():
|
1689
|
-
|
1686
|
+
def disconnect() -> None:
|
1687
|
+
_on_config_parsed.disconnect(receiver)
|
1690
1688
|
|
1691
|
-
def func_with_lock():
|
1689
|
+
def func_with_lock() -> None:
|
1692
1690
|
if lock:
|
1693
1691
|
with _config_lock:
|
1694
1692
|
func()
|
streamlit/config_util.py
CHANGED
@@ -54,19 +54,19 @@ def show_config(
|
|
54
54
|
)
|
55
55
|
)
|
56
56
|
|
57
|
-
def append_desc(text):
|
57
|
+
def append_desc(text: str) -> None:
|
58
58
|
out.append("# " + cli_util.style_for_cli(text, bold=True))
|
59
59
|
|
60
|
-
def append_comment(text):
|
60
|
+
def append_comment(text: str) -> None:
|
61
61
|
out.append("# " + cli_util.style_for_cli(text))
|
62
62
|
|
63
|
-
def append_section(text):
|
63
|
+
def append_section(text: str) -> None:
|
64
64
|
out.append(cli_util.style_for_cli(text, bold=True, fg="green"))
|
65
65
|
|
66
|
-
def append_setting(text):
|
66
|
+
def append_setting(text: str) -> None:
|
67
67
|
out.append(cli_util.style_for_cli(text, fg="green"))
|
68
68
|
|
69
|
-
for section in section_descriptions
|
69
|
+
for section in section_descriptions:
|
70
70
|
# We inject a fake config section used for unit tests that we exclude here as
|
71
71
|
# its options are often missing required properties, which confuses the code
|
72
72
|
# below.
|
@@ -178,8 +178,7 @@ def _clean_paragraphs(txt: str) -> list[str]:
|
|
178
178
|
# Strip both leading and trailing newlines.
|
179
179
|
txt = txt.strip("\n")
|
180
180
|
paragraphs = txt.split("\n\n")
|
181
|
-
|
181
|
+
return [
|
182
182
|
"\n".join(_clean(line) for line in paragraph.split("\n"))
|
183
183
|
for paragraph in paragraphs
|
184
184
|
]
|
185
|
-
return cleaned_paragraphs
|
@@ -207,7 +207,7 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
207
207
|
host=conn_params["host"],
|
208
208
|
port=int(conn_params["port"]) if "port" in conn_params else None,
|
209
209
|
database=conn_params.get("database"),
|
210
|
-
query=conn_params
|
210
|
+
query=conn_params.get("query", {}),
|
211
211
|
)
|
212
212
|
|
213
213
|
create_engine_kwargs = ChainMap(
|
streamlit/dataframe_util.py
CHANGED
@@ -1067,7 +1067,7 @@ def is_colum_type_arrow_incompatible(column: Series[Any] | Index) -> bool:
|
|
1067
1067
|
"complex",
|
1068
1068
|
]:
|
1069
1069
|
return True
|
1070
|
-
|
1070
|
+
if inferred_type == "mixed":
|
1071
1071
|
# This includes most of the more complex/custom types (objects, dicts,
|
1072
1072
|
# lists, ...)
|
1073
1073
|
if len(column) == 0 or not hasattr(column, "iloc"):
|
@@ -1079,7 +1079,7 @@ def is_colum_type_arrow_incompatible(column: Series[Any] | Index) -> bool:
|
|
1079
1079
|
# Get the first value to check if it is a supported list-like type.
|
1080
1080
|
first_value = column.iloc[0]
|
1081
1081
|
|
1082
|
-
if (
|
1082
|
+
if ( # noqa: SIM103
|
1083
1083
|
not is_list_like(first_value)
|
1084
1084
|
# dicts are list-like, but have issues in Arrow JS (see comments in
|
1085
1085
|
# Quiver.ts)
|
@@ -1164,53 +1164,53 @@ def determine_data_format(input_data: Any) -> DataFormat:
|
|
1164
1164
|
|
1165
1165
|
if input_data is None:
|
1166
1166
|
return DataFormat.EMPTY
|
1167
|
-
|
1167
|
+
if isinstance(input_data, pd.DataFrame):
|
1168
1168
|
return DataFormat.PANDAS_DATAFRAME
|
1169
|
-
|
1169
|
+
if isinstance(input_data, np.ndarray):
|
1170
1170
|
if len(cast("NumpyShape", input_data.shape)) == 1:
|
1171
1171
|
# For technical reasons, we need to distinguish one
|
1172
1172
|
# one-dimensional numpy array from multidimensional ones.
|
1173
1173
|
return DataFormat.NUMPY_LIST
|
1174
1174
|
return DataFormat.NUMPY_MATRIX
|
1175
|
-
|
1175
|
+
if isinstance(input_data, pa.Table):
|
1176
1176
|
return DataFormat.PYARROW_TABLE
|
1177
|
-
|
1177
|
+
if isinstance(input_data, pa.Array):
|
1178
1178
|
return DataFormat.PYARROW_ARRAY
|
1179
|
-
|
1179
|
+
if isinstance(input_data, pd.Series):
|
1180
1180
|
return DataFormat.PANDAS_SERIES
|
1181
|
-
|
1181
|
+
if isinstance(input_data, pd.Index):
|
1182
1182
|
return DataFormat.PANDAS_INDEX
|
1183
|
-
|
1183
|
+
if is_pandas_styler(input_data):
|
1184
1184
|
return DataFormat.PANDAS_STYLER
|
1185
|
-
|
1185
|
+
if isinstance(input_data, pd.api.extensions.ExtensionArray):
|
1186
1186
|
return DataFormat.PANDAS_ARRAY
|
1187
|
-
|
1187
|
+
if is_polars_series(input_data):
|
1188
1188
|
return DataFormat.POLARS_SERIES
|
1189
|
-
|
1189
|
+
if is_polars_dataframe(input_data):
|
1190
1190
|
return DataFormat.POLARS_DATAFRAME
|
1191
|
-
|
1191
|
+
if is_polars_lazyframe(input_data):
|
1192
1192
|
return DataFormat.POLARS_LAZYFRAME
|
1193
|
-
|
1193
|
+
if is_modin_data_object(input_data):
|
1194
1194
|
return DataFormat.MODIN_OBJECT
|
1195
|
-
|
1195
|
+
if is_snowpandas_data_object(input_data):
|
1196
1196
|
return DataFormat.SNOWPANDAS_OBJECT
|
1197
|
-
|
1197
|
+
if is_pyspark_data_object(input_data):
|
1198
1198
|
return DataFormat.PYSPARK_OBJECT
|
1199
|
-
|
1199
|
+
if is_xarray_dataset(input_data):
|
1200
1200
|
return DataFormat.XARRAY_DATASET
|
1201
|
-
|
1201
|
+
if is_xarray_data_array(input_data):
|
1202
1202
|
return DataFormat.XARRAY_DATA_ARRAY
|
1203
|
-
|
1203
|
+
if is_ray_dataset(input_data):
|
1204
1204
|
return DataFormat.RAY_DATASET
|
1205
|
-
|
1205
|
+
if is_dask_object(input_data):
|
1206
1206
|
return DataFormat.DASK_OBJECT
|
1207
|
-
|
1207
|
+
if is_snowpark_data_object(input_data) or is_snowpark_row_list(input_data):
|
1208
1208
|
return DataFormat.SNOWPARK_OBJECT
|
1209
|
-
|
1209
|
+
if is_duckdb_relation(input_data):
|
1210
1210
|
return DataFormat.DUCKDB_RELATION
|
1211
|
-
|
1211
|
+
if is_dbapi_cursor(input_data):
|
1212
1212
|
return DataFormat.DBAPI_CURSOR
|
1213
|
-
|
1213
|
+
if (
|
1214
1214
|
isinstance(
|
1215
1215
|
input_data,
|
1216
1216
|
(ChainMap, UserDict, MappingProxyType),
|
@@ -1221,9 +1221,9 @@ def determine_data_format(input_data: Any) -> DataFormat:
|
|
1221
1221
|
or is_pydantic_model(input_data)
|
1222
1222
|
):
|
1223
1223
|
return DataFormat.KEY_VALUE_DICT
|
1224
|
-
|
1224
|
+
if isinstance(input_data, (ItemsView, enumerate)):
|
1225
1225
|
return DataFormat.LIST_OF_ROWS
|
1226
|
-
|
1226
|
+
if isinstance(input_data, (list, tuple, set, frozenset)):
|
1227
1227
|
if _is_list_of_scalars(input_data):
|
1228
1228
|
# -> one-dimensional data structure
|
1229
1229
|
if isinstance(input_data, tuple):
|
@@ -1231,15 +1231,14 @@ def determine_data_format(input_data: Any) -> DataFormat:
|
|
1231
1231
|
if isinstance(input_data, (set, frozenset)):
|
1232
1232
|
return DataFormat.SET_OF_VALUES
|
1233
1233
|
return DataFormat.LIST_OF_VALUES
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
return DataFormat.LIST_OF_ROWS
|
1234
|
+
# -> Multi-dimensional data structure
|
1235
|
+
# This should always contain at least one element,
|
1236
|
+
# otherwise the values type from infer_dtype would have been empty
|
1237
|
+
first_element = next(iter(input_data))
|
1238
|
+
if isinstance(first_element, dict):
|
1239
|
+
return DataFormat.LIST_OF_RECORDS
|
1240
|
+
if isinstance(first_element, (list, tuple, set, frozenset)):
|
1241
|
+
return DataFormat.LIST_OF_ROWS
|
1243
1242
|
elif isinstance(input_data, (dict, Mapping)):
|
1244
1243
|
if not input_data:
|
1245
1244
|
return DataFormat.KEY_VALUE_DICT
|
@@ -1340,7 +1339,7 @@ def convert_pandas_df_to_data_format(
|
|
1340
1339
|
DataFormat.SNOWPARK_OBJECT,
|
1341
1340
|
}:
|
1342
1341
|
return df
|
1343
|
-
|
1342
|
+
if data_format == DataFormat.NUMPY_LIST:
|
1344
1343
|
import numpy as np
|
1345
1344
|
|
1346
1345
|
# It's a 1-dimensional array, so we only return
|
@@ -1348,48 +1347,48 @@ def convert_pandas_df_to_data_format(
|
|
1348
1347
|
# Calling to_numpy() on the full DataFrame would result in:
|
1349
1348
|
# [[1], [2]] instead of [1, 2]
|
1350
1349
|
return np.ndarray(0) if df.empty else df.iloc[:, 0].to_numpy()
|
1351
|
-
|
1350
|
+
if data_format == DataFormat.NUMPY_MATRIX:
|
1352
1351
|
import numpy as np
|
1353
1352
|
|
1354
1353
|
return np.ndarray(0) if df.empty else df.to_numpy()
|
1355
|
-
|
1354
|
+
if data_format == DataFormat.PYARROW_TABLE:
|
1356
1355
|
import pyarrow as pa
|
1357
1356
|
|
1358
1357
|
return pa.Table.from_pandas(df)
|
1359
|
-
|
1358
|
+
if data_format == DataFormat.PYARROW_ARRAY:
|
1360
1359
|
import pyarrow as pa
|
1361
1360
|
|
1362
1361
|
return pa.Array.from_pandas(_pandas_df_to_series(df))
|
1363
|
-
|
1362
|
+
if data_format == DataFormat.PANDAS_SERIES:
|
1364
1363
|
return _pandas_df_to_series(df)
|
1365
|
-
|
1364
|
+
if data_format in {DataFormat.POLARS_DATAFRAME, DataFormat.POLARS_LAZYFRAME}:
|
1366
1365
|
import polars as pl # type: ignore[import-not-found]
|
1367
1366
|
|
1368
1367
|
return pl.from_pandas(df)
|
1369
|
-
|
1368
|
+
if data_format == DataFormat.POLARS_SERIES:
|
1370
1369
|
import polars as pl
|
1371
1370
|
|
1372
1371
|
return pl.from_pandas(_pandas_df_to_series(df))
|
1373
|
-
|
1372
|
+
if data_format == DataFormat.XARRAY_DATASET:
|
1374
1373
|
import xarray as xr # type: ignore[import-not-found]
|
1375
1374
|
|
1376
1375
|
return xr.Dataset.from_dataframe(df)
|
1377
|
-
|
1376
|
+
if data_format == DataFormat.XARRAY_DATA_ARRAY:
|
1378
1377
|
import xarray as xr
|
1379
1378
|
|
1380
1379
|
return xr.DataArray.from_series(_pandas_df_to_series(df))
|
1381
|
-
|
1380
|
+
if data_format == DataFormat.LIST_OF_RECORDS:
|
1382
1381
|
return _unify_missing_values(df).to_dict(orient="records")
|
1383
|
-
|
1382
|
+
if data_format == DataFormat.LIST_OF_ROWS:
|
1384
1383
|
# to_numpy converts the dataframe to a list of rows
|
1385
1384
|
return _unify_missing_values(df).to_numpy().tolist()
|
1386
|
-
|
1385
|
+
if data_format == DataFormat.COLUMN_INDEX_MAPPING:
|
1387
1386
|
return _unify_missing_values(df).to_dict(orient="dict")
|
1388
|
-
|
1387
|
+
if data_format == DataFormat.COLUMN_VALUE_MAPPING:
|
1389
1388
|
return _unify_missing_values(df).to_dict(orient="list")
|
1390
|
-
|
1389
|
+
if data_format == DataFormat.COLUMN_SERIES_MAPPING:
|
1391
1390
|
return df.to_dict(orient="series")
|
1392
|
-
|
1391
|
+
if data_format in [
|
1393
1392
|
DataFormat.LIST_OF_VALUES,
|
1394
1393
|
DataFormat.TUPLE_OF_VALUES,
|
1395
1394
|
DataFormat.SET_OF_VALUES,
|
@@ -1409,7 +1408,7 @@ def convert_pandas_df_to_data_format(
|
|
1409
1408
|
if data_format == DataFormat.SET_OF_VALUES:
|
1410
1409
|
return set(return_list)
|
1411
1410
|
return return_list
|
1412
|
-
|
1411
|
+
if data_format == DataFormat.KEY_VALUE_DICT:
|
1413
1412
|
df = _unify_missing_values(df)
|
1414
1413
|
# The key is expected to be the index -> this will return the first column
|
1415
1414
|
# as a dict with index as key.
|
streamlit/delta_generator.py
CHANGED
@@ -522,9 +522,12 @@ class DeltaGenerator(
|
|
522
522
|
|
523
523
|
def _block(
|
524
524
|
self,
|
525
|
-
block_proto: Block_pb2.Block =
|
525
|
+
block_proto: Block_pb2.Block | None = None,
|
526
526
|
dg_type: type | None = None,
|
527
527
|
) -> DeltaGenerator:
|
528
|
+
if block_proto is None:
|
529
|
+
block_proto = Block_pb2.Block()
|
530
|
+
|
528
531
|
# Operate on the active DeltaGenerator, in case we're in a `with` block.
|
529
532
|
dg = self._active_dg
|
530
533
|
|
streamlit/deprecation_util.py
CHANGED
@@ -93,7 +93,7 @@ def deprecate_func_name(
|
|
93
93
|
"""
|
94
94
|
|
95
95
|
@functools.wraps(func)
|
96
|
-
def wrapped_func(*args, **kwargs):
|
96
|
+
def wrapped_func(*args: Any, **kwargs: Any) -> Any:
|
97
97
|
result = func(*args, **kwargs)
|
98
98
|
show_deprecation_warning(
|
99
99
|
make_deprecated_name_warning(
|
@@ -167,7 +167,7 @@ def _create_deprecated_obj_wrapper(obj: TObj, show_warning: Callable[[], Any]) -
|
|
167
167
|
show_warning()
|
168
168
|
|
169
169
|
class Wrapper:
|
170
|
-
def __init__(self):
|
170
|
+
def __init__(self) -> None:
|
171
171
|
# Override all the Wrapped object's magic functions
|
172
172
|
for name in Wrapper._get_magic_functions(obj.__class__):
|
173
173
|
setattr(
|
@@ -176,7 +176,7 @@ def _create_deprecated_obj_wrapper(obj: TObj, show_warning: Callable[[], Any]) -
|
|
176
176
|
property(self._make_magic_function_proxy(name)),
|
177
177
|
)
|
178
178
|
|
179
|
-
def __getattr__(self, attr):
|
179
|
+
def __getattr__(self, attr: str) -> Any:
|
180
180
|
# We handle __getattr__ separately from our other magic
|
181
181
|
# functions. The wrapped class may not actually implement it,
|
182
182
|
# but we still need to implement it to call all its normal
|
@@ -199,8 +199,8 @@ def _create_deprecated_obj_wrapper(obj: TObj, show_warning: Callable[[], Any]) -
|
|
199
199
|
]
|
200
200
|
|
201
201
|
@staticmethod
|
202
|
-
def _make_magic_function_proxy(name):
|
203
|
-
def proxy(
|
202
|
+
def _make_magic_function_proxy(name: str) -> Callable[[Any], Any]:
|
203
|
+
def proxy(_self: Any, *args: Any) -> Any:
|
204
204
|
maybe_show_warning()
|
205
205
|
return getattr(obj, name)
|
206
206
|
|
streamlit/elements/arrow.py
CHANGED
@@ -563,7 +563,7 @@ class ArrowMixin:
|
|
563
563
|
if use_container_width is None:
|
564
564
|
# If use_container_width was not explicitly set by the user, we set
|
565
565
|
# it to True if width was not set explicitly, and False otherwise.
|
566
|
-
use_container_width =
|
566
|
+
use_container_width = width is None
|
567
567
|
|
568
568
|
proto.use_container_width = use_container_width
|
569
569
|
|
@@ -456,10 +456,7 @@ class PydeckMixin:
|
|
456
456
|
|
457
457
|
ctx = get_script_run_ctx()
|
458
458
|
|
459
|
-
if pydeck_obj is None
|
460
|
-
spec = json.dumps(EMPTY_MAP)
|
461
|
-
else:
|
462
|
-
spec = pydeck_obj.to_json()
|
459
|
+
spec = json.dumps(EMPTY_MAP) if pydeck_obj is None else pydeck_obj.to_json()
|
463
460
|
|
464
461
|
pydeck_proto.json = spec
|
465
462
|
pydeck_proto.use_container_width = use_container_width
|
streamlit/elements/doc_string.py
CHANGED
@@ -283,9 +283,7 @@ def _get_variable_name_from_code_str(code: str) -> str | None:
|
|
283
283
|
):
|
284
284
|
# A common pattern is to add "," at the end of a magic command to make it print.
|
285
285
|
# This removes that final ",", so it looks nicer.
|
286
|
-
|
287
|
-
|
288
|
-
return code
|
286
|
+
return code.removesuffix(",")
|
289
287
|
|
290
288
|
arg_node = _get_stcommand_arg(tree)
|
291
289
|
|
@@ -427,7 +425,7 @@ def _get_weight(value: Any) -> int:
|
|
427
425
|
return 0
|
428
426
|
|
429
427
|
|
430
|
-
def _get_value(obj, var_name):
|
428
|
+
def _get_value(obj: object, var_name: str | None) -> str | None:
|
431
429
|
obj_value = _get_human_readable_value(obj)
|
432
430
|
|
433
431
|
if obj_value is not None:
|
@@ -449,10 +447,7 @@ def _get_value(obj, var_name):
|
|
449
447
|
sig = _get_signature(name_obj) or ""
|
450
448
|
|
451
449
|
if name:
|
452
|
-
if module
|
453
|
-
obj_value = f"{module}.{name}{sig}"
|
454
|
-
else:
|
455
|
-
obj_value = f"{name}{sig}"
|
450
|
+
obj_value = f"{module}.{name}{sig}" if module else f"{name}{sig}"
|
456
451
|
|
457
452
|
if obj_value == var_name:
|
458
453
|
# No need to repeat the same info.
|
@@ -462,7 +457,7 @@ def _get_value(obj, var_name):
|
|
462
457
|
return obj_value
|
463
458
|
|
464
459
|
|
465
|
-
def _get_human_readable_value(value):
|
460
|
+
def _get_human_readable_value(value: Any) -> str | None:
|
466
461
|
if isinstance(value, Secrets):
|
467
462
|
# Don't want to read secrets.toml because that will show a warning if there's no
|
468
463
|
# secrets.toml file.
|
@@ -511,7 +506,7 @@ def _is_computed_property(obj: object, attr_name: str) -> bool:
|
|
511
506
|
return False
|
512
507
|
|
513
508
|
|
514
|
-
def _get_members(obj):
|
509
|
+
def _get_members(obj: object) -> list[MemberProto]:
|
515
510
|
members_for_sorting = []
|
516
511
|
|
517
512
|
for attr_name in dir(obj):
|
streamlit/elements/exception.py
CHANGED
@@ -232,10 +232,9 @@ def _format_syntax_error_message(exception: SyntaxError) -> str:
|
|
232
232
|
|
233
233
|
"""
|
234
234
|
if exception.text:
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
caret_indent = ""
|
235
|
+
caret_indent = (
|
236
|
+
" " * max(exception.offset - 1, 0) if exception.offset is not None else ""
|
237
|
+
)
|
239
238
|
|
240
239
|
return (
|
241
240
|
'File "%(filename)s", line %(lineno)s\n'
|
@@ -362,9 +361,8 @@ def _split_list(
|
|
362
361
|
saw_split_point = False
|
363
362
|
|
364
363
|
for item in orig_list:
|
365
|
-
if not saw_split_point:
|
366
|
-
|
367
|
-
saw_split_point = True
|
364
|
+
if not saw_split_point and split_point(item):
|
365
|
+
saw_split_point = True
|
368
366
|
|
369
367
|
if saw_split_point:
|
370
368
|
after.append(item)
|
streamlit/elements/layouts.py
CHANGED
@@ -184,7 +184,7 @@ class LayoutsMixin:
|
|
184
184
|
self,
|
185
185
|
spec: SpecType,
|
186
186
|
*,
|
187
|
-
gap: Literal["small", "medium", "large"] = "small",
|
187
|
+
gap: Literal["small", "medium", "large", "none"] = "small",
|
188
188
|
vertical_alignment: Literal["top", "center", "bottom"] = "top",
|
189
189
|
border: bool = False,
|
190
190
|
) -> list[DeltaGenerator]:
|
@@ -213,7 +213,7 @@ class LayoutsMixin:
|
|
213
213
|
Or ``[1, 2, 3]`` creates three columns where the second one is two times
|
214
214
|
the width of the first one, and the third one is three times that width.
|
215
215
|
|
216
|
-
gap : "small", "medium", or "
|
216
|
+
gap : "small", "medium", "large", or "none"
|
217
217
|
The size of the gap between the columns. The default is ``"small"``.
|
218
218
|
|
219
219
|
vertical_alignment : "top", "center", or "bottom"
|
@@ -359,11 +359,12 @@ class LayoutsMixin:
|
|
359
359
|
"small": GapSize.SMALL,
|
360
360
|
"medium": GapSize.MEDIUM,
|
361
361
|
"large": GapSize.LARGE,
|
362
|
+
"none": GapSize.NONE,
|
362
363
|
}
|
363
364
|
|
364
365
|
if isinstance(gap, str):
|
365
366
|
gap_size = gap.lower()
|
366
|
-
valid_sizes =
|
367
|
+
valid_sizes = gap_mapping.keys()
|
367
368
|
|
368
369
|
if gap_size in valid_sizes:
|
369
370
|
return gap_mapping[gap_size]
|